package com.hospital.system.controller;

import com.hospital.common.domain.system.UserInfo;
import com.hospital.common.result.R;
import com.hospital.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：sjc
 * @Description:
 * @name：UserController
 * @Date：2024/10/18 18:58
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;


    /**
     * 查询用户
     * @param patient
     * @return
     */
    @PostMapping("findUserList")
    public R<UserInfo> findUserList(@RequestBody UserInfo patient){
        UserInfo patient1 = userService.findUser(patient);
        return R.success(patient1);
    }


    /**
     * 注册
     * @param patientVo
     * @return
     */
    @PostMapping("register")
    public R register(@RequestBody UserInfo patientVo){
        userService.save(patientVo);
        return R.success("ok了");
    }


    /**
     * 查询用户名
     * @param patientName
     * @return
     */
    @PostMapping("selectUserName")
    public R<UserInfo> selectUserName(@RequestBody String patientName){
        UserInfo patient = userService.selectUser(patientName);
        return R.success(patient);
    }
}
